<?php
abstract class RequestAdapter {
	public $httpVersion = 'HTTP/1.1';
	public $uri;
	public $verb = 'GET';
	public $headers = array();
	public $body;
	public $requestTimeout = 100;
	public $proxy = null;
	public $code = 0;
	protected $_listeners = array();
	public $cookie = array();
	public function setListeners(&$listeners){
		$this->_listeners &= $listeners;
	}

	public function sendRequest(){}
	 /**
    * Processes the response header
    *
    * @access private
    * @param  string    HTTP header
    */
    protected function processHeader($header)
    {
        if (strpos($header, ':') === false) {
            return;
        }
        list($headername, $headervalue) = explode(':', $header, 2);
        if (strstr($headername,'-')) {
            list($p1,$p2) = explode('-',$headername);
            $headername  = ucfirst(strtolower($p1)).'-'.ucfirst(strtolower($p2));
        }
        else {
            $headername  = ucfirst($headername);
        }
        $headervalue = ltrim($headervalue);

        if ('set-cookie' != $headername) {
            if (isset($this->headers[$headername])) {
                $this->headers[$headername] .= ',' . $headervalue;
            } else {
                $this->headers[$headername]  = $headervalue;
            }
        } else {
            $this->cookies[] = $this->parseCookie($headervalue);
        }
    }
}